<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
Object obj=request.getSession().getAttribute("role_resource");
if(null==obj){
	response.setStatus(1000);
	return;
}
%> 
	<script type="text/javascript">
	
		//定义操作类型
		var oper_type;
		
		//城市树数据源
		var tree_store = new Ext.data.JsonStore({
    		root: "data",
    		totalProperty: "total",
    		fields: ["cityno","cityname","parentno","flag"],
    		url: "tree!city.action"
    	});
    	//城市列表数据源
    	var data_store = new Ext.data.JsonStore({
    		root: "data",
    		totalProperty: "total",
    		fields: ["cityno","cityname","parentno","flag"],
    		url: "city!list.action"
    	});
    	//定义数据显示面板
		var p1 = {
			id: "p1",
			xtype: "grid",
			region: "center",
			stripeRows:true,
			loadMask : true,//在加载数据时遮罩住元素,替换元素Updater的加载提示器，并且在初始化加载之后销毁
			autoExpandColumn:"cityname",//自动填充
			autoExpandMin : 100,//自动填充最小宽度
			store: data_store,
			headersDisabled: true,
			columns:[
	        	new Ext.grid.RowNumberer({header: "序号", width:35}),
    					{header: "区号",			dataIndex: "cityno",	menuDisabled: true},
    					{header: "名称",			dataIndex: "cityname", id: "cityname", menuDisabled: true}
			],
			bbar: new Ext.ux.PagingToolbar({
				id:"cityPaging",
            	pageSize: limit,
            	store: data_store
        	})
		};
		
		var city_pel =new Ext.Panel({
			border : false, 
			layout: "border",
			items: [{
				id: "cityTree",
				xtype: "billTreePanel",
				dataUrl: "tree!city.action",
				autoScroll: true,
				root: new Ext.tree.AsyncTreeNode({
					id: "root",
					expanded : true		// 自动展开节点
				}),
				listeners: {
					"click": function(node){
						tree_store.load({params:{node:node.attributes.id}});
						data_store.baseParams = data_store.baseParams || {};
						if(node.isLeaf()) {
							data_store.baseParams["city.cityno"] = node.attributes.id;
							delete data_store.baseParams["city.parentno"];
						} else {
							data_store.baseParams["city.parentno"] = node.attributes.id;
							delete data_store.baseParams["city.cityno"];
						}
						data_store.load({params:{start : 0,limit : limit}});
					}
				}
			}, p1]
		});	

	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(city_pel);
	CenterPanel.doLayout();
	</script>
